package com.block.api.controller.sys;

import com.alibaba.fastjson.JSONObject;
import com.block.common.exception.ApiException;
import com.block.common.security.util.ApiUtil;
import com.block.common.vo.ResponseVo;
import com.block.db.entity.AppEncrypt;
import com.block.db.entity.ApplicationInfo;
import com.block.db.entity.ChannelBaseInfo;
import com.block.sms.service.ISmsRecordService;
import com.block.tool.service.IToolsNewsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("api/tools")
@Validated
public class ToolsController {

    @Autowired
    IToolsNewsInfoService toolsNewsInfoService;

    /**
     * 获取最新的新闻列表
     */
    @RequestMapping(value = "/getNewsList", method = {RequestMethod.POST, RequestMethod.GET})
    public String getNewsList(@RequestAttribute(value = "tranData") JSONObject tranData,
                              @RequestAttribute(value = "appEncrypt") AppEncrypt appEncrypt,
                                @RequestAttribute(value = "channelBaseInfo") ChannelBaseInfo channelBaseInfo,
                                @RequestAttribute(value = "applicationInfo") ApplicationInfo applicationInfo,
                                @RequestAttribute(value = "uri") String uri,
                                @RequestAttribute(value = "startDate") Date startdate,
                                @RequestAttribute(value = "ip") String ip) throws ApiException {


        ResponseVo responseVo = toolsNewsInfoService.getNewsList();
        return ApiUtil.dealReturnJson(responseVo, appEncrypt, startdate, uri);
    }

}
